home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-I386 / PROCESSO.{_D < prev    next >
Text File  |  1999-09-17  |  9KB  |  322 lines

  1. /*
  2.  * include/asm-i386/processor.h
  3.  *
  4.  * Copyright (C) 1994 Linus Torvalds
  5.  */
  6.  
  7. #ifndef __ASM_I386_PROCESSOR_H
  8. #define __ASM_I386_PROCESSOR_H
  9.  
  10. #include <asm/vm86.h>
  11. #include <asm/math_emu.h>
  12. #include <asm/segment.h>
  13. #include <asm/page.h>
  14.  
  15. /*
  16.  *  CPU type and hardware bug flags. Kept separately for each CPU.
  17.  *  Members of this structure are referenced in head.S, so think twice
  18.  *  before touching them. [mj]
  19.  */
  20.  
  21. struct cpuinfo_x86 {
  22.     __u8    x86;        /* CPU family */
  23.     __u8    x86_vendor;    /* CPU vendor */
  24.     __u8    x86_model;
  25.     __u8    x86_mask;
  26.     char    wp_works_ok;    /* It doesn't on 386's */
  27.     char    hlt_works_ok;    /* Problems on some 486Dx4's and old 386's */
  28.     char    hard_math;
  29.     char    rfu;
  30.     int    cpuid_level;    /* Maximum supported CPUID level, -1=no CPUID */
  31.     __u32    x86_capability;
  32.     char    x86_vendor_id[16];
  33.     char    x86_model_id[64];
  34.     int     x86_cache_size;  /* in KB - valid for CPUS which support this
  35.                     call  */
  36.     int    fdiv_bug;
  37.     int    f00f_bug;
  38.     unsigned long loops_per_sec;
  39.     unsigned long *pgd_quick;
  40.     unsigned long *pte_quick;
  41.     unsigned long pgtable_cache_sz;
  42. };
  43.  
  44. #define X86_VENDOR_INTEL 0
  45. #define X86_VENDOR_CYRIX 1
  46. #define X86_VENDOR_AMD 2
  47. #define X86_VENDOR_UMC 3
  48. #define X86_VENDOR_NEXGEN 4
  49. #define X86_VENDOR_CENTAUR 5
  50. #define X86_VENDOR_UNKNOWN 0xff
  51.  
  52. /*
  53.  * capabilities of CPUs
  54.  */
  55.  
  56. #define X86_FEATURE_FPU        0x00000001    /* onboard FPU */
  57. #define X86_FEATURE_VME        0x00000002    /* Virtual Mode Extensions */
  58. #define X86_FEATURE_DE        0x00000004    /* Debugging Extensions */
  59. #define X86_FEATURE_PSE        0x00000008    /* Page Size Extensions */
  60. #define X86_FEATURE_TSC        0x00000010    /* Time Stamp Counter */
  61. #define X86_FEATURE_MSR        0x00000020    /* Model-Specific Registers, RDMSR, WRMSR */
  62. #define X86_FEATURE_PAE        0x00000040    /* Physical Address Extensions */
  63. #define X86_FEATURE_MCE        0x00000080    /* Machine Check Exceptions */
  64. #define X86_FEATURE_CX8        0x00000100    /* CMPXCHG8 instruction */
  65. #define X86_FEATURE_APIC    0x00000200    /* onboard APIC */
  66. #define X86_FEATURE_10        0x00000400
  67. #define X86_FEATURE_SEP        0x00000800    /* Fast System Call */ 
  68. #define X86_FEATURE_MTRR    0x00001000    /* Memory Type Range Registers */
  69. #define X86_FEATURE_PGE        0x00002000    /* Page Global Enable */
  70. #define X86_FEATURE_MCA        0x00004000    /* Machine Check Architecture */
  71. #define X86_FEATURE_CMOV    0x00008000    /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
  72. #define X86_FEATURE_PAT    0x00010000    /* Page Attribute Table */
  73. #define X86_FEATURE_PSE36    0x00020000    /* 36-bit PSEs */
  74. #define X86_FEATURE_18        0x00040000
  75. #define X86_FEATURE_19        0x00080000
  76. #define X86_FEATURE_20        0x00100000
  77. #define X86_FEATURE_21        0x00200000
  78. #define X86_FEATURE_22        0x00400000
  79. #define X86_FEATURE_MMX        0x00800000    /* multimedia extensions */
  80. #define X86_FEATURE_FXSR    0x01000000    /* FXSAVE and FXRSTOR instructions (fast save and restore of FPU context), and CR4.OSFXSR (OS uses these instructions) available */
  81. #define X86_FEATURE_25        0x02000000
  82. #define X86_FEATURE_26        0x04000000
  83. #define X86_FEATURE_27        0x08000000
  84. #define X86_FEATURE_28        0x10000000
  85. #define X86_FEATURE_29        0x20000000
  86. #define X86_FEATURE_30        0x40000000
  87. #define X86_FEATURE_AMD3D    0x80000000
  88.  
  89. extern struct cpuinfo_x86 boot_cpu_data;
  90.  
  91. #ifdef __SMP__
  92. extern struct cpuinfo_x86 cpu_data[];
  93. #define current_cpu_data cpu_data[smp_processor_id()]
  94. #else
  95. #define cpu_data &boot_cpu_data
  96. #define current_cpu_data boot_cpu_data
  97. #endif
  98.  
  99. extern char ignore_irq13;
  100.  
  101. extern void identify_cpu(struct cpuinfo_x86 *);
  102. extern void print_cpu_info(struct cpuinfo_x86 *);
  103. extern void dodgy_tsc(void);
  104.  
  105. /*
  106.  *    Generic CPUID function
  107.  */
  108. extern inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx)
  109. {
  110.     __asm__("cpuid"
  111.         : "=a" (*eax),
  112.           "=b" (*ebx),
  113.           "=c" (*ecx),
  114.           "=d" (*edx)
  115.         : "a" (op)
  116.         : "cc");
  117. }
  118.  
  119. /*
  120.  *      Cyrix CPU configuration register indexes
  121.  */
  122. #define CX86_CCR2 0xc2
  123. #define CX86_CCR3 0xc3
  124. #define CX86_CCR4 0xe8
  125. #define CX86_CCR5 0xe9
  126. #define CX86_DIR0 0xfe
  127. #define CX86_DIR1 0xff
  128.  
  129. /*
  130.  *      Cyrix CPU indexed register access macros
  131.  */
  132.  
  133. #define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
  134.  
  135. #define setCx86(reg, data) do { \
  136.     outb((reg), 0x22); \
  137.     outb((data), 0x23); \
  138. } while (0)
  139.  
  140. /*
  141.  * Bus types (default is ISA, but people can check others with these..)
  142.  */
  143. extern int EISA_bus;
  144. extern int MCA_bus;
  145.  
  146. /* from system description table in BIOS.  Mostly for MCA use, but
  147. others may find it useful. */
  148. extern unsigned int machine_id;
  149. extern unsigned int machine_submodel_id;
  150. extern unsigned int BIOS_revision;
  151.  
  152. /*
  153.  * User space process size: 3GB (default).
  154.  */
  155. #define TASK_SIZE    (PAGE_OFFSET)
  156.  
  157. /* This decides where the kernel will search for a free chunk of vm
  158.  * space during mmap's.
  159.  */
  160. #define TASK_UNMAPPED_BASE    (TASK_SIZE / 3)
  161.  
  162. /*
  163.  * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
  164.  */
  165. #define IO_BITMAP_SIZE    32
  166.  
  167. struct i387_hard_struct {
  168.     long    cwd;
  169.     long    swd;
  170.     long    twd;
  171.     long    fip;
  172.     long    fcs;
  173.     long    foo;
  174.     long    fos;
  175.     long    st_space[20];    /* 8*10 bytes for each FP-reg = 80 bytes */
  176.     long    status;        /* software status information */
  177. };
  178.  
  179. struct i387_soft_struct {
  180.     long    cwd;
  181.     long    swd;
  182.     long    twd;
  183.     long    fip;
  184.     long    fcs;
  185.     long    foo;
  186.     long    fos;
  187.     long    st_space[20];    /* 8*10 bytes for each FP-reg = 80 bytes */
  188.     unsigned char    ftop, changed, lookahead, no_update, rm, alimit;
  189.     struct info    *info;
  190.     unsigned long    entry_eip;
  191. };
  192.  
  193. union i387_union {
  194.     struct i387_hard_struct hard;
  195.     struct i387_soft_struct soft;
  196. };
  197.  
  198. typedef struct {
  199.     unsigned long seg;
  200. } mm_segment_t;
  201.  
  202. struct thread_struct {
  203.     unsigned short    back_link,__blh;
  204.     unsigned long    esp0;
  205.     unsigned short    ss0,__ss0h;
  206.     unsigned long    esp1;
  207.     unsigned short    ss1,__ss1h;
  208.     unsigned long    esp2;
  209.     unsigned short    ss2,__ss2h;
  210.     unsigned long    cr3;
  211.     unsigned long    eip;
  212.     unsigned long    eflags;
  213.     unsigned long    eax,ecx,edx,ebx;
  214.     unsigned long    esp;
  215.     unsigned long    ebp;
  216.     unsigned long    esi;
  217.     unsigned long    edi;
  218.     unsigned short    es, __esh;
  219.     unsigned short    cs, __csh;
  220.     unsigned short    ss, __ssh;
  221.     unsigned short    ds, __dsh;
  222.     unsigned short    fs, __fsh;
  223.     unsigned short    gs, __gsh;
  224.     unsigned short    ldt, __ldth;
  225.     unsigned short    trace, bitmap;
  226.     unsigned long    io_bitmap[IO_BITMAP_SIZE+1];
  227.     unsigned long    tr;
  228.     unsigned long    cr2, trap_no, error_code;
  229.     mm_segment_t    segment;
  230. /* debug registers */
  231.     long debugreg[8];  /* Hardware debugging registers */
  232. /* floating point info */
  233.     union i387_union i387;
  234. /* virtual 86 mode info */
  235.     struct vm86_struct * vm86_info;
  236.     unsigned long screen_bitmap;
  237.     unsigned long v86flags, v86mask, v86mode, saved_esp0;
  238. };
  239.  
  240. #define INIT_MMAP \
  241. { &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
  242.  
  243. #define INIT_TSS  {                        \
  244.     0,0, /* back_link, __blh */                \
  245.     sizeof(init_stack) + (long) &init_stack, /* esp0 */    \
  246.     __KERNEL_DS, 0, /* ss0 */                \
  247.     0,0,0,0,0,0, /* stack1, stack2 */            \
  248.     (long) &swapper_pg_dir - PAGE_OFFSET, /* cr3 */        \
  249.     0,0, /* eip,eflags */                    \
  250.     0,0,0,0, /* eax,ecx,edx,ebx */                \
  251.     0,0,0,0, /* esp,ebp,esi,edi */                \
  252.     0,0,0,0,0,0, /* es,cs,ss */                \
  253.     0,0,0,0,0,0, /* ds,fs,gs */                \
  254.     _LDT(0),0, /* ldt */                    \
  255.     0, 0x8000, /* tace, bitmap */                \
  256.     {~0, }, /* ioperm */                    \
  257.     _TSS(0), 0, 0, 0, (mm_segment_t) { 0 }, /* obsolete */    \
  258.     { 0, },                            \
  259.     { { 0, }, },  /* 387 state */                \
  260.     NULL, 0, 0, 0, 0, 0, /* vm86_info */            \
  261. }
  262.  
  263. #define start_thread(regs, new_eip, new_esp) do {        \
  264.     __asm__("movl %w0,%%fs ; movl %w0,%%gs": :"r" (0));    \
  265.     set_fs(USER_DS);                    \
  266.     regs->xds = __USER_DS;                    \
  267.     regs->xes = __USER_DS;                    \
  268.     regs->xss = __USER_DS;                    \
  269.     regs->xcs = __USER_CS;                    \
  270.     regs->eip = new_eip;                    \
  271.     regs->esp = new_esp;                    \
  272. } while (0)
  273.  
  274. /* Forward declaration, a strange C thing */
  275. struct mm_struct;
  276.  
  277. /* Free all resources held by a thread. */
  278. extern void release_thread(struct task_struct *);
  279. extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
  280.  
  281. /* Copy and release all segment info associated with a VM */
  282. extern void copy_segments(int nr, struct task_struct *p, struct mm_struct * mm);
  283. extern void release_segments(struct mm_struct * mm);
  284. extern void forget_segments(void);
  285.  
  286. /*
  287.  * FPU lazy state save handling..
  288.  */
  289. #define save_fpu(tsk) do { \
  290.     asm volatile("fnsave %0\n\tfwait":"=m" (tsk->tss.i387)); \
  291.     tsk->flags &= ~PF_USEDFPU; \
  292.     stts(); \
  293. } while (0)
  294.  
  295. #define unlazy_fpu(tsk) do { \
  296.     if (tsk->flags & PF_USEDFPU) \
  297.         save_fpu(tsk); \
  298. } while (0)
  299.  
  300. #define clear_fpu(tsk) do { \
  301.     if (tsk->flags & PF_USEDFPU) { \
  302.         tsk->flags &= ~PF_USEDFPU; \
  303.         stts(); \
  304.     } \
  305. } while (0)
  306.  
  307. /*
  308.  * Return saved PC of a blocked thread.
  309.  */
  310. extern inline unsigned long thread_saved_pc(struct thread_struct *t)
  311. {
  312.     return ((unsigned long *)t->esp)[3];
  313. }
  314.  
  315. extern struct task_struct * alloc_task_struct(void);
  316. extern void free_task_struct(struct task_struct *);
  317.  
  318. #define init_task    (init_task_union.task)
  319. #define init_stack    (init_task_union.stack)
  320.  
  321. #endif /* __ASM_I386_PROCESSOR_H */
  322.